//和call 的思路一致，就是要判断下 arguments[1]，arguments[1] 为undefined的话是不能使用扩展运算符的，会报错
Function.prototype.myApply = function(context=window){
    let key = Symbol();
    context[key] = this;
    var res;
    if(arguments[1]){
        res = context[key](...arguments[1]);
    }else{
        res = context[key]();
    }
    delete context[key];
    return res;
}

var obj = {name:"katy",age: 30};

function test(name,age){
    console.log(this.name);
    console.log(`name is:${name},age is:${age}`);
}

// test.myApply(obj,["win7",29]);
test.myApply(obj);